package com.example.demo2.mapper;

import com.example.demo2.entity.Feedback;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FeedbackMapper {
    @Insert("insert into feedback(backId,detectorId,feedback,backTime,backStatus) " +
            "values(NULL,#{feedback.detectorId},#{feedback.feedback},#{feedback.backTime},0)")
    public int insertFeedback(@Param("feedback") Feedback feedback);
    @Select("select * from feedback ")
    public List<Feedback> getAllfeedback ();

    @Update("update feedback set sponsorId = #{spoid},response = #{response},resTime = #{restime},backStatus = 1 where backId = #{backId}")
    public int addResponse(@Param("spoid") int spoid , @Param("response") String response , @Param("restime") String restime , @Param("backId") int backid);

    @Select("select uRealName from users where uId = #{uid}")
    public String finduRealNameById(@Param("uid") int uid);

    @Select("select * from feedback where backId = #{backid}")
    public Feedback findBackAndSpoById(@Param("backid") int backid);

    @Select("select * from feedback where detectorId=#{detectorId}  ORDER BY backTime ASC")
    public List<Feedback> getFeedback(@Param("detectorId") int detectorId);
}
